{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">编辑</h3>

	<table class="layui-table">

		<tr>
			<td class="layui-td-gray">部门名称<font>*</font></td>
			<td >
				<input type="text" name="name" lay-verify="required" {notempty name="$detail.name"}value="{$detail.name}"{else/}value=""{/notempty} autocomplete="off" placeholder="请输入" class="layui-input">
			</td>
			<td class="layui-td-gray">所在地区<font>*</font></td>
			<td>
				<select name="area_id" lay-verify="required" lay-search lay-reqText="请选择地区">
					<option value="">请选择，输入关键字检索</option>
					{volist name="area_list" id="v"}
					<option value="{$v.id}" {notempty name="$detail.area_id"}{eq name="$detail.area_id" value="$v.id"} selected{/eq}{/notempty}>{$v.name}</option>
					{/volist}
				</select>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">部门全称</td>
			<td >
				<input type="text" name="full_name" {notempty name="$detail.full_name"}value="{$detail.full_name}"{else/}value=""{/notempty} autocomplete="off" placeholder="请输入" class="layui-input">
			</td>
		</tr>

	</table>

	<div class="py-3">
		<input type="hidden" name="id" {notempty name='$detail.id'}value="{$detail.id}"{/notempty}>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,laydate = layui.laydate;

		//监听提交
		form.on('submit(webform)', function(data){
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					setTimeout(function () {
						parent.location.reload();
					}, 1000);
				}
			}
			tool.post("/matter/unit/add", data.field, callback);
			return false;
		});

	}
</script>
{/block}
<!-- /脚本 -->